/**
 * Created by Void on 2017/7/12.
 */

(function (doc, win) {
  var docEl = doc.documentElement,
    resizeEvt = 'orientationchange' in win ? 'orientationchange' : 'resize',
    recalc = function () {
      var clientWidth = docEl.clientWidth;
      if (!clientWidth) return;
      docEl.style.fontSize = 10 * (clientWidth / 375) + 'px';
    };

  if (!doc.addEventListener) return;
  win.addEventListener(resizeEvt, recalc, false);
  doc.addEventListener('DOMContentLoaded', recalc, false);
  if (/Android [3-8]/.test(navigator.appVersion)) {
    win.addEventListener('resize', function () {
      if (doc.activeElement.tagName == 'INPUT' || doc.activeElement.tagName == 'TEXTAREA') {
        win.setTimeout(function () {
          doc.activeElement.scrollIntoView();
        }, 0);
      }
    })
  }
  
})(document, window);